<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8" />
    <title>场景切换</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            overflow: hidden;
        }

        .container {
            height: 100%;
            background-color: rgb(28, 25, 57);
        }

        .scene1 {
            display: block;
            height: 50%;
            /* background-color: bisque; */
            transition: opacity 1s;
            background-image: linear-gradient(135deg,
                    #f5f5f5 20%,
                    #f9fad4 20%, #f9fad4 40%,
                    #f5f5f5 40%, #f5f5f5 60%,
                    #f8eaf0 60%, #f8eaf0 80%,
                    #f5f5f5 80%, #f5f5f5 100%);
        }

        .scene2 {
            display: none;
            height: 50%;
            background-color: rgb(28, 25, 57);
            color: red;
            opacity: 0;
            transition: opacity 1s;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="scene1">
            <div>
                sth in scene1
            </div>
            <button onclick="goToScene2()">
                切换到场景2
            </button>
        </div>
        <div class="scene2">
            sth in scene 2
        </div>
    </div>
    <button onclick="scene2OpacityChange()"
        style="position: absolute;bottom: 10px;right: 10px; height: 100px; height: 50px;">scene2 opacity change</button>

    <script>
        function goToScene2() {
            console.log("切换到场景2");
            document.querySelector(".scene1").style.opacity = 0;
            setTimeout(function () {
                document.querySelector(".scene1").style.display = "none";
                document.querySelector(".scene2").style.display = "block";
            }, 1000);
            setTimeout(function () {
                document.querySelector(".scene2").style.opacity = 1;
            }, 1030);
        }
        function scene2OpacityChange() {
            document.querySelector(".scene2").style.opacity = 1;
        }
    </script>
</body>

</html>